using System;
using System.Collections.Generic;
using System.Text;
using SharpMud.Server.Systems.Net;

namespace SharpMud.Net
{
	public interface IHostedConnectionHandler
	{
        /// <summary>
        /// Initialize the handler with the connection to be handled, and the host
        /// of the two
        /// </summary>
        /// <param name="connection">The connection to initialize the handler with</param>
        /// <param name="host">The host of the network connection and handler</param>
        /// <exception cref="InvalidOperationException">Thrown if the handler has already been initialized</exception>
        void Initialize(INetworkConnection connection, INetworkSystem host);

        /// <summary>
        /// The network connection that this IHostedConnectionHandler is responsible for
        /// </summary>
        INetworkConnection Connection { get;}

        /// <summary>
        /// The host INetworkSystem of the connection and its handler
        /// </summary>
        INetworkSystem Host { get;}
	}

    /// <summary>
    /// Represents an IHostedConnectionHandler that uses session states
    /// </summary>
    public interface IHasSessionState : IHostedConnectionHandler
    {
        ISessionStateStack SessionState { get;}
    }

    /// <summary>
    /// A generic form of IHasSessionState that indicates that the session states are statically
    /// aware of the System.Type of the session (IHostedConnectionHandler) object
    /// </summary>
    /// <typeparam name="TSession"></typeparam>
    public interface IHasSessionState<TSession> : IHasSessionState where TSession : IHasSessionState<TSession>
    {
        ISessionStateStack<TSession> SessionState { get;}
    }
}